var NAV = {};
(function(){
	var lis = document.getElementById("nav").getElementsByTagName("a"),
			frame_btn = document.getElementById("frame_btn"),
			lisNum = lis.length,
			i;
	
	//当前项
	for(i=0;i<lisNum;i++){
			lis[i].onclick=function(){
					for (var j=0;j<lisNum;j++){
							lis[j].parentNode.className = "";
					}
					this.parentNode.className="current";
					if (this.parentNode.nodeName.toLowerCase() != "h2"){
							this.parentNode.parentNode.parentNode.getElementsByTagName("h2")[0].className="current";
					}
			};
	}
		
	//导航 收缩展开
	frame_btn.onclick = function(){
			var that = this;
			if (that.className == "opened"){
					parent.document.getElementsByTagName("frameset")[1].cols = "10,*";
					that.className = "closed";
			}else if(that.className == "closed"){
					parent.document.getElementsByTagName("frameset")[1].cols = "175,*";
					that.className = "opened";
			}
	}
	
	NAV.current = function(cateIndex,liIndex){
			for (var j=0;j<lisNum;j++){
					lis[j].parentNode.className = "";
			}
			lis[cateIndex].parentNode.className = lis[liIndex].parentNode.className = "current";
	}
	
	window.onload = function(){
			var href = this.location.href,
					nav = window.top.document.getElementsByTagName("frameset")[1],
					btn = document.getElementById("frame_btn");
			if(/hideNav/.test(href)){
					nav.cols = "10,*";
					btn.className = "closed";
			}else{
					nav.cols = "175,*";
					btn.className = "opened";
			}
	}
})();